package com.liberty.apollo;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;

@EnableApolloConfig
public class ApolloTest {

	public static void main(String[] args) {
		ExecutorService executor = Executors.newFixedThreadPool(2);
		ExecutorService executor2 = Executors.newSingleThreadExecutor();
		final CountDownLatch countDownLatch = new CountDownLatch(1);
		final CountDownLatch countDownLatch2 = new CountDownLatch(1);
		executor.execute(new Runnable() {

			@Override
			public void run() {
				try {
					Thread.sleep(10 * 1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				countDownLatch.countDown();
			}
		});

		executor.execute(new Runnable() {

			@Override
			public void run() {
				try {
					countDownLatch2.await();
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				System.out.println("2ok");
			}
		});
		
		executor2.execute(new Runnable() {

			@Override
			public void run() {
				try {
					Thread.sleep(1 * 1000);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				countDownLatch2.countDown();
			}
		});
		executor.shutdown();

		try {
			countDownLatch.await();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("ok");

	}
}
